<%-- 
    Document   : AddBookIssue
    Created on : Mar 26, 2014, 3:59:32 PM
    Author     : mishra
--%>
<%@page import="java.util.Calendar"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    try {
        if (session.getAttribute("uid") != null) {
            if (session.getAttribute("Book_Issue").toString().equals("1")) {
%>
<%String to = "", status = "", msg = "";%>
<!DOCTYPE html>
<html>
    <head>
        <title>Ramgovind Automated System</title>

        <link rel="stylesheet" href="/RIT/css/bootstrap.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="/RIT/css/jquery.fancybox.css">
        <link rel="stylesheet" href="/RIT/css/style.css">
        <link rel="stylesheet" href="/RIT/css/iconfont.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap.datepicker.css">
        <script src="../../ajax/ajax.js"></script>
        <script>
            function getEmpStuName(seid)
            {
                var utype=document.getElementById('utype').value;
                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                { 
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {   
                        var a=xmlhttp.responseText;
                        if(a.length!=0)
                        {
                            document.getElementById('esname').value =a;   
                        }
                    else
                    {
                        alert('Does Not Exist in Record');
                    }
                }
            }
                xmlhttp.open("POST","/RIT/getEmpStuName?seid="+seid+"&utype="+utype,false);
                xmlhttp.send();
            }
            
            function getBookName(bid)
            {
                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                { 
                    
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    { 
                        if(xmlhttp.responseText.length!=0){
                        document.getElementById('bname').value = xmlhttp.responseText;
                        }
                        else{
                            alert('Book Already Issued');
                        }
                    }
                }
                xmlhttp.open("POST","/RIT/getBookName?bookid="+bid,false);
                xmlhttp.send();
            }
            
            function getReturnDate(bookid)
            {
                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                        
                        document.getElementById('rdate').value = xmlhttp.responseText;
                        
                    }
                }
                
                xmlhttp.open("POST","/RIT/getRetruningDate?book="+bookid,false);
                xmlhttp.send();
            }  
            function setValue(val)
            {
                document.getElementById('utype').value=val;
                document.getElementById('nocode').value="";
                document.getElementById('esname').value="";
                
            }
        </script>

    </head>
    <body>
        <%
            Calendar calendar = Calendar.getInstance();
            int month = calendar.get(Calendar.MONTH) + 1;
            String date = calendar.get(Calendar.YEAR) + "/" + month + "/" + calendar.get(Calendar.DATE);
        %>
        <%@include file="/topheader.html" %>
        <%@include file="/servicesheader.html" %>
        <div class="main">
            <div class="container-fluid">
                <%@include file="/Services/Library/librarysidenav.jsp" %>
                <div class="content">
                    <%if (session.getAttribute("status") != null) {
                            status = session.getAttribute("status").toString();
                            msg = session.getAttribute("msg").toString();
                    %>
                    <div class="alert alert-success alert-block">
                        <a class="close" data-dismiss="alert" href="#"><img src="/RIT/img/mclose.png"></a>
                        <h4 class="alert-heading"> <%=status%></h4>
                        <%=msg%>

                    </div>
                    <%session.removeAttribute("status");
                            session.removeAttribute("msg");
                        }%>
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="box">
                                <div class="box-head">
                                    <h3>Book Issue</h3>
                                    <!--<a href="BookIssue.jsp">
                                        <button style="float: right" class="btn btn-success">View Books Issue</button>
                                    </a>-->
                                </div>
                                
                                <form action="/RIT/BookIssue" method="post" class='validate form-horizontal'>
                                    <div class="box-content">
                                        <!---Form Start....-->

                                        <div id="lside" style="float: left; margin-top: 10px;">

                                            <div class="control-group">
                                                <label for="bcat" class="control-label">Issue</label>
                                                <div class="controls">
                                                    <input type="radio" name="issue" id="issue" class='required' value="1" onclick="setValue(this.value)">&nbsp;&nbsp;Staff 
                                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <input type="radio" name="issue" id="issue1" class='required' value="2" onclick="setValue(this.value)">&nbsp;&nbsp;Student
                                                    <input type="hidden" id="utype" name="utype">
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label for="bname" class="control-label">Admission No./ Employee Code</label>
                                                <div class="controls">
                                                    <input type="text" name="nocode" id="nocode" class='required' onblur="getEmpStuName(this.value)">
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="bno" class="control-label">Book No.</label>
                                                <div class="controls">
                                                    <input type="text" name="bno" id="bno" class='required' onblur="getBookName(this.value), getReturnDate(document.getElementById('bno').value)">
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label for="idate" class="control-label">Issue Date</label>
                                                <div class="controls">
                                                    <input type="text" name="idate" id="idate" class='required' readonly value="<%=date%>">
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="rdate" class="control-label">Returning Date</label>
                                                <div class="controls">
                                                    <input type="text" name="rdate" id="rdate" readOnly>
                                                </div>
                                            </div>
                                        </div>
                                        <div id="rside" style="float: right; margin-right: 120px; margin-top: 10px">
                                            <div class="control-group">
                                                <label for="price" class="control-label"></label>
                                                <div class="controls">
                                                    <div class="input-append">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="price" class="control-label">Employee/ Student Name</label>
                                                <div class="controls">
                                                    <div class="input-append">
                                                        <input type="text" name="esname" id="esname" class='{required:true}' readonly="">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="fine" class="control-label">Book Name</label>
                                                <div class="controls">
                                                    <div class="input-append">
                                                        <input type="text" name="bname" id="bname"  class='{required:true}' readonly="">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-actions">
                                        <input type="submit" class='btn btn-primary'>
                                    </div>
                                </form>
                                <!---Form Ends....-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="/RIT/js/jquery.js"></script>
        <script src="/RIT/js/less.js"></script>
        <script src="/RIT/js/bootstrap.min.js"></script>
        <script src="/RIT/js/jquery.uniform.min.js"></script>
        <script src="/RIT/js/bootstrap.timepicker.js"></script>
        <script src="/RIT/js/bootstrap.datepicker.js"></script>
        <script src="/RIT/js/chosen.jquery.min.js"></script>
        <script src="/RIT/js/jquery.fancybox.js"></script>
        <script src="/RIT/js/plupload/plupload.full.js"></script>
        <script src="/RIT/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
        <script src="/RIT/js/jquery.cleditor.min.js"></script>
        <script src="/RIT/js/jquery.inputmask.min.js"></script>
        <script src="/RIT/js/jquery.tagsinput.min.js"></script>
        <script src="/RIT/js/jquery.mousewheel.js"></script>
        <script src="/RIT/js/jquery.textareaCounter.plugin.js"></script>
        <script src="/RIT/js/ui.spinner.js"></script>
        <script src="/RIT/js/jquery.jgrowl_minimized.js"></script>
        <script src="/RIT/js/jquery.form.js"></script>
        <script src="/RIT/js/jquery.validate.min.js"></script>
        <script src="/RIT/js/bbq.js"></script>
        <script src="/RIT/js/jquery-ui-1.8.22.custom.min.js"></script>
        <script src="/RIT/js/jquery.form.wizard-min.js"></script>
        <script src="/RIT/js/jquery.cookie.js"></script>
        <script src="/RIT/js/jquery.metadata.js"></script>
        <script src="/RIT/js/custom.js"></script><script src="/RIT/js/demo.js"></script>
        <script src="/RIT/js/iconfont.js"></script>
    </body>
</html>
<%} else {
    out.println("<script>alert('" + session.getAttribute("Enquiry") + "')</script>");
%>
<script type="text/javascript">
    alert("You Are Not Authorised");
    window.history.back();
</script>
<%
            }
        } else {
            request.setAttribute("msg", "You Are Not Authorised! Please Contact to System Administrator!");
            request.setAttribute("value", "0");
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
        }
    } catch (Exception e) {
        request.setAttribute("msg", "Please Contact to System Administrator!");
        request.setAttribute("value", "0");
        getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
        
%>

